package fr.umlv.ig.model;


/**
 * Represents a Itinerary.
 * A Line in an metro contains Itinerary.
 * Itinerary object is final with a public visibility. You can just 
 * modified the object in his package.
 * @author Jenseric Catbgan
 * @author William Choy
 * 
 */
public class Itinerary {
	/** the first {@link Station} of the itinerary */
	private final Station start;
	
	/** the Station terminus of the itinerary*/
	private final Station end;
	
	
	/**
	 * Initializes an Itinerary with a station departure and a terminus station.
	 * @param start the departure station.
	 * @param end the terminus station.
	 */
	public Itinerary(Station start, Station end) {
		if(start == null || end == null) {
			throw new NullPointerException("one or the two stations are null");
		}
		this.start = start;
		this.end = end;
		
	}

	/**
	 * Returns the departure station.
	 * @return the departure station.
	 */
	Station getStart() {
		return start;
	}

	/**
	 * Returns the terminus station.
	 * @return the terminus station.
	 */
	Station getEnd() {
		return end;
	}
	
	
	/**
	 * Returns the Line of the itinerary.
	 * @return the Line of the Itinerary.
	 */
	Line getLine() {
		return start.getLine();
	}
	
	
	@Override
	public boolean equals(Object obj) {
		if(obj == this) {
			return true;
		}
		if(!( obj instanceof Itinerary)) {
			return false;
		}
		Itinerary itinerary = (Itinerary) obj;
		return start.equals(itinerary.start) && end.equals(itinerary.end);
	}
	
	@Override
	public int hashCode() {
		return start.hashCode() ^ end.hashCode();
	}
}
